package gerador.base;

import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Set;
import java.util.Map.Entry;

import org.xml.sax.InputSource;
import org.xmlmiddleware.schemas.dtds.DTD;
import org.xmlmiddleware.schemas.dtds.DTDParser;
import org.xmlmiddleware.schemas.dtds.ElementType;
import org.xmlmiddleware.utils.XMLMiddlewareException;
import org.xmlmiddleware.xmlutils.XMLName;

public class xmlTest {

	public static void main(String[] args) throws MalformedURLException, EOFException, XMLMiddlewareException, IOException {
		DTDParser parser = new DTDParser();
		InputSource source = new InputSource(new FileInputStream(new File("resource/euclid_issue.dtd")));
		DTD dtd = parser.parseExternalSubset(source, null);
		Enumeration<ElementType> elements = dtd.elementTypes.elements();
		while (elements.hasMoreElements()) {
			ElementType element = elements.nextElement();
			if (element.parents.entrySet().size() == 0) {
				System.out.println(element.name.getLocalName());
				Enumeration<ElementType> e = element.children.elements();
				while (e.hasMoreElements()) {
					System.out.println(e.nextElement().name.getLocalName());
				}
			}
		}
		
	}
}
